{% extends "DataMinerBundle:Page:layout.html.twig" %}

{% block documentReady %}
    {{ parent() }}
 /*   // add parser through the tablesorter addParser method 
    $.tablesorter.addParser({ 
        // set a unique id 
        id: 'gold', 
        is: function(s) { 
            // return false so this parser is not auto detected 
            return false; 
        }, 
        format: function(s) { 
            // format your data for normalization 
            return parseInt(s.replace(/ /g,"")); 
        }, 
        // set type, either numeric or text 
        type: 'numeric' 
    }); 
    $(function() { 
        $("table").tablesorter({ 
            headers: { 
                2: { 
                    sorter:'gold' 
                } 
            } 
        }); 
    });         
*/
    $("#sellerTable").tablesorter( {sortList: [[2,1]]} ); 
    $("#characterTable").tablesorter( {sortList: [[3,1]]} );
    
{% endblock documentReady %}


{% block content %}
    {{sellers}}
{% endblock %}

{% block content2 %}
<H1>Others {{ chars | length }}</H1>
        <table id="characterTable" class="items table table-striped table-condensed table-bordered character tablesorter">
            <thead>
            <tr>
                <th>Server</th><th>Name</th><th>Gold</th><th>Last Seen</th><th>Last Gather</th>
            </tr>
            </thead>
            <tbody>
    {% for char in chars %}

            <a href=''>
                <tr  {% if char.isOnline() %} {% if char.isStuck() %} class="stuck"{% endif %} class="online"{% endif %}> 
                <td>{{char.server.name}}</td>
                <td>{{char.name}}</td>
                <td style="text-align: right">{{char.gold|number_format(0,',','.') }}</td>
                {% set hours = char.timeLastSeen() / (60*60) %}
                {% set min = (char.timeLastSeen() % (60*60)) / 60 %} 
                <td style="text-align: right">{{ hours | number_format(0)}}h{{ min | number_format(0)}}m</td>            
                <td style="text-align: right">{% if char.lastGather %} {{ char.timeSinceLastGather }} {% endif  %}</td>            </tr>
            </a>
            </tr>
    {% else %}
        <p>There are no characters in the DB</p>
    {% endfor %}
</tbody>
</table>
{% endblock %}
